package ysc.cqnu.operdb.serviceImpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import ysc.cqnu.operdb.entity.Assemble;
import ysc.cqnu.operdb.entity.ResultData;
import ysc.cqnu.operdb.mapper.ZhuangpeiMapper;
import ysc.cqnu.operdb.service.CheckZhuangPeiInfoService;

@Service
public class CheckZhuangPeiInfoServiceImpl implements CheckZhuangPeiInfoService {
    @Autowired
    private ResultData resultData;
    @Autowired
    private Assemble assemble;
    @Autowired
    private ZhuangpeiMapper zhuangpeiMapper;

    @Override
    public ResultData checkZhuangPeiInfoService(String zhuangpeiname, String renwu, String yongtu, String juti, String uploader, String uploadDate) {
        try {
            assemble = zhuangpeiMapper.chazhaoZhuangpeiInfo(zhuangpeiname,renwu,yongtu,juti,uploader,uploadDate);
            if(assemble!=null){
                int count = zhuangpeiMapper.count();
                int site = zhuangpeiMapper.zhuangpeiInfoSite(String.valueOf(assemble.getId()));
                assemble.Count=String.valueOf(count);
                assemble.site=String.valueOf(site);
                resultData.flag="CheckSuccess";
                resultData.data=assemble;
                return resultData;
            }
            else {
                resultData.flag="ZhuangpeiInfoNoFind";
                resultData.data=null;
                return resultData;
            }
        }catch (Exception e){
            resultData.flag="CheckFail";
            resultData.data=null;
            return resultData;
        }
    }
}
